
<div class="easyui-layout" data-options="fit:true,border:false">
	<div data-options="region:'center',border:false">
		<@eu.datagrid id="deviceEventList"  pagination="false" rownumbers="false" toolbar="#deviceEventList_toolbar"  url="jmax/loadEventGridDatas.do?loadGridDatas" item="com.xdtech.jmax.vo.DeviceEventLogItem" />
		<div id="deviceEventList_toolbar" style="height: auto">
			<@eu.linkbutton showName="刷新" shiro="sys:log:refresh" iconCls="icon-reload" onclick="reloadDeviceEvent()"/>
		</div>
	</div>
</div> 
<script>
	function reloadDeviceEvent() {
		deviceEventList.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		deviceEventList.datagrid('unselectAll');
		deviceEventList.datagrid('uncheckAll');
	}
	function loadEventData() {
		$.post('jmax/loadEventGridDatas.do?loadGridDatas',function(result){
            if (result.rows.length>0){
            	for (var i = 0; i <result.rows.length ; i++) {
            		deviceEventList.datagrid('insertRow',{
            			index: 0,	
            			row: result.rows[i]
            		});
            	}
            }
            var rows = deviceEventList.datagrid('getRows');
    		printLog(rows.length);
    		if(rows.length>100) {
    			for (var i = rows.length-1; i>=100 ; i--) {
    				var index = deviceEventList.datagrid('getRowIndex',rows[i]);
            		deviceEventList.datagrid('deleteRow',index);
            	}
    		}
        },'json');
		
	}
	setInterval(loadEventData,2000);
</script>